//
//  QCComposeButton.swift
//  SwiftDemoWithSina
//
//  Created by qu on 2017/2/8.
//  Copyright © 2017年 Apple. All rights reserved.
//

import UIKit

class QCComposeButton: UIButton {

    var composeModel: QCComposeModel?
    
   //设置按钮放大动画后 如果button 按钮存在高亮效果 会导致空间偏移 需要干掉高亮效果
   override var isHighlighted: Bool {
        get {
            return false
        }
        
        set {
            
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //重新布局子控件
    override func layoutSubviews() {
        super.layoutSubviews()
        imageView?.frame.size = CGSize(width: self.frame.size.width, height: self.frame.size.width)
        imageView?.frame.origin.y = 0
        
        titleLabel?.frame.size = CGSize(width: self.frame.size.width, height: self.frame.size.height - self.frame.size.width)
        //设置X Y
        titleLabel?.frame.origin.x = 0
        titleLabel?.frame.origin.y = self.frame.size.width
    }
    
    private func setupUI(){
       //设置imageView的填充模式
      imageView?.contentMode = .center
//        imageView?.backgroundColor = UIColor.yellow
        //titleLabel的文字对齐方式
        titleLabel?.textAlignment = .center
        //字体
        titleLabel?.font = UIFont.systemFont(ofSize: QCNORMALFONTSIZE)
        //颜色
        setTitleColor(UIColor.darkGray, for: UIControlState.normal)
        
    }

}
